<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>权限管理-总控后台</title>
		<link rel="shortcut icon" href="favicon.ico">
		<link rel="stylesheet" href="../layui/css/layui.css">
	</head>

	<body>
		<div style="padding: 15px;">
			<!-- 页面内容 Start -->
			<blockquote class="layui-elem-quote layui-text">
				权限编辑
			</blockquote>
			<div class="layui-card layui-panel">
				<div class="layui-card-body">
					<form class="layui-form" action="" style="margin: 20px;">
						<div class="layui-form-item">
							<label class="layui-form-label">标题</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" name="title" lay-verify="required" placeholder="请输入标题"
									autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">类型</label>
							<div class="layui-input-block">
								<input type="radio" name="type" value="1" title="菜单">
								<input type="radio" name="type" value="2" title="按钮">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">图标</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" name="icon" placeholder="请输入图标" autocomplete="off"
									class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">页面路由</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" name="page_routing" autocomplete="off" placeholder="请输入页面路由"
									lay-affix="clear" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">Api路由</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" name="api_routing" autocomplete="off" placeholder="请输入Api路由"
									lay-affix="clear" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">上级权限</label>
							<div class="layui-input-inline layui-input-wrap">
								<select name="parent_id" lay-filter="aihao">
									<option value="" selected>请选择</option>
									<option value="0">首级</option>
								</select>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">排序</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="number" name="sort" lay-verify="required" autocomplete="off"
									placeholder="请输入排序" lay-affix="clear" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">权限检查</label>
							<div class="layui-input-block">
								<input type="radio" name="checkk" value="1" title="是">
								<input type="radio" name="checkk" value="2" title="否">
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
								<!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
								<button type="button" id="closeIframe" class="layui-btn layui-btn-primary">关闭</button>
							</div>
						</div>
					</form>
				</div>
			</div>
			<!-- 页面内容 End -->
		</div>
		<script src="../layui/layui.js"></script>
		<script src="../layui/js/global_config.js"></script>
		<script type="text/javascript">
			layui.use(['form', 'ajax'], function() {
				var form = layui.form;
				var layer = layui.layer;
				var $ = layui.$
				var ajax = layui.ajax;
				
				var index = parent.layer.getFrameIndex(window.name);

				// 提交事件
				form.on('submit(demo1)', function(data) {
					var field = data.field; // 获取表单字段值
					// 此处可执行 Ajax 等操作
					ajax.post('./', field)
					// $.ajax({
					// 	url: './',
					// 	data: field,
					// 	type: 'POST',
					// 	dataType: "JSON",
					// 	error: function(error) {
					// 		layer.msg(error.msg);
					// 	},
					// 	success: function(res) {
					// 		layer.msg('提交成功', {
					// 			icon: 6,
					// 			time: 1000, // 提示音乐播放的时间，默认3秒
					// 		}, function() {
					// 			// 关闭之后的回调
					// 			// window.location.href = "/authlist";
					// 			// 关闭当前子页面
					// 			parent.layer.close(index);
					// 			// 调用父页面的方法来刷新表格
					// 			parent.refreshTable();
					// 		});
					// 	}
					// });
					// …
					return false; // 阻止默认 form 跳转
				});

				// 关闭当前子页面
				$('#closeIframe').click(function() {
					parent.layer.close(index);
				});

			});
		</script>
	</body>
</html>